<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
                 <link rel="stylesheet" href="style.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
                
                <script language="javascript">
                    function prompt(){
                        var question = confirm("Are you sure you want to delete this student profile?");
                        if(question)
                           return true;
                        
                        else return false;
                           
                    }
                    
                    
                    function archiveprompt(){
                        var question = confirm("Are you sure you want to continue archiving? \n\n Note: The current set of student grades can no longer be updated  once archived.");
                        if(question)
                           return true;
                        
                        else return false;
                           
                    }
                    
               
                    
                </script>
                
                
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">VIEW STUDENTS</a></li>
                                        <li><a href="view.php">BACK</a></li>
				
				</ul>
			</div>
			<div class="body">

<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
      include 'PHPClasses/DBAccess.php';
      include 'PHPClasses/StudentDBAccess.php';
      include 'PHPClasses/GradeComputation.php';
      
       error_reporting(E_ERROR | E_PARSE);
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
    
    $DBAccess=new StudentDBAccess();
    $studentList=$DBAccess->viewDB();
    
       
     echo "<table id=hor-minimalist-a>";
     echo "<thead><tr><th scope=col>Student Name</th>
            <th scope=col>Q1</th>
            <th scope=col>Q2</th>
            <th scope=col>Q3</th>
            <th scope=col>Q4</th>
            <th scope=col>Total</th></tr></thead>";
     
     $getStudents=mysql_num_rows($studentList);
     if($getStudents==0){
           echo "<td scope=col>No Students Added!</td>";
     }
        
    $level='';
      
    $gc=new GradeComputation();  
            while ($row = mysql_fetch_array($studentList))
            {
                extract($row);
                    if($level!=$studentlvl)
                {
                       $level=$studentlvl;
                        echo "<tr><th>$level</th>
                            <th scope=col></th>
                            <th scope=col></th>
                            <th scope=col></th>
                            <th scope=col></th>
                            <th scope=col></th></tr>\n";
                }
              
                
              $first=$gc->computeQuarterAverage($idStudent,'1st Quarter',$studentlvl,0);
              $second=$gc->computeQuarterAverage($idStudent,'2nd Quarter',$studentlvl,0);
              $third=$gc->computeQuarterAverage($idStudent,'3rd Quarter',$studentlvl,0);
              $fourth=$gc->computeQuarterAverage($idStudent,'4th Quarter',$studentlvl,0);
              $total=$gc->computeTotalAverage($idStudent,$studentlvl,0);
              
              if($passed==0){
                echo "<td><a href='viewStudentProfile.php?studentID=".$idStudent."' style='text-decoration:none; color:red;'>$studentName</td></a>\n";
              }
              
              else{
                echo "<td><a href='viewStudentProfile.php?studentID=".$idStudent."' style='text-decoration:none; color:green;'>$studentName</td></a>\n";
              }
              
               echo "       
              <td>$first</td>\n
              <td>$second</td>\n
              <td>$third</td>\n
              <td>$fourth</td>\n
              <td>$total</td>\n";

            echo "
                </form></td><td><form name='studentIDForm' action='deleteStudentProfile.php' onsubmit='return prompt()'method='POST'>
                <input type='hidden' value='$idStudent' name='studentID'/><input type='submit' class='addmore' value='Delete Profile'/>\n
                </form></td></tr>";
              
                 
            }
            
           
            echo "</table>\n<br/><br/><br/><br/>";
            
           if($getStudents!=0){
            echo "<table><td><form name='studentArchiveForm' action='archiveGrades.php' onsubmit='return archiveprompt()' method='POST'>
           <input type='submit' id='archive' class='addmore' value='Archive Grades' name='archive'/></form></td>      
           </form></td></table>\n";
            
           }
    
    
    $DBAccess->DBDisconnect();
?>
                         
                        </div>
                    
			<div class="footer">
				
				<p>&#169; Copyright &#169; 2011. Company name all rights reserved</p>
				<div class="connect">
					<a href=""><img src="images/paragox.png" width=160" height="110" alt=""/></a>
					<a href=""><img src="images/fblogo.png" width=120" height="100" alt="" style="position:relative; left:-31px"/></a>
					<a href=""><img src="images/harmony.png" width=120" height="100" alt="" style="position:relative; left:0px"/></a>
				</div>
			</div>
		</div>
	</body>
</html> 